package com.cloudkinto.bo.order;

import com.cloudkinto.bo.common.BaseQueryBo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author Administrator
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "亚马逊订单查询条件")
public class OrderAmazonQueryBo extends BaseQueryBo {
    @ApiModelProperty("订单号(模糊查)")
    private String orderNumber;

    @ApiModelProperty("购买人(模糊查)")
    private String shipName;

    @ApiModelProperty("购买人联系电话(模糊查)")
    private String shipPhone;

    @ApiModelProperty("sku(模糊查)")
    private String sku;

    @ApiModelProperty("开始时间")
    private String startTime;

    @ApiModelProperty("结束时间")
    private String endTime;

    @ApiModelProperty("订单状态")
    private String orderStatus;

    @ApiModelProperty("店铺id")
    private String shopId;

    @ApiModelProperty("转运")
    private String fulfillmentChannel;

    @ApiModelProperty("是否配送")
    private String isSend;

    public Date getStartTime() {
        if (StringUtils.isBlank(startTime)) {
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(startTime, format).atTime(0, 0, 0);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }

    public Date getEndTime() {
        if (StringUtils.isBlank(endTime)) {
            return null;
        }
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDateTime dateTime = LocalDate.parse(endTime, format).atTime(23, 59, 59);
        return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
    }
}
